home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
UTILITY
/
DO1002.ARJ
/
IF.SCR
< prev
next >
Wrap
Text File
|
1991-12-28
|
6KB
|
166 lines
.pg wi full clr
»cy«COMMAND NAME»gray«: »%t« Compare »ye«
/IF {value1} {EQ|LT|GT|NE|GE|LE|LK} {value} [[{else label}][ ASIS]]
/cw
Compare examines two values as:
»cy«EQ»gray« - »cy«{value1}»#« equal to »cy«{value}
»cy«LT»gray« - »cy«{value1}»#« less than »cy«{value}
»cy«GT»gray« - »cy«{value1}»#« greater than »cy«{value}
»cy«NE»gray« - »cy«{value1}»#« not equal to »cy«{value}
»cy«GE»gray« - »cy«{value1}»#« greater than or equal to »cy«{value}
»cy«LE»gray« - »cy«{value1}»#« less than or equal to »cy«{value}
»cy«IN»gray« - »cy«{value1}»#« appears in »cy«{value}
»cy«LK»gray« - »cy«{value1}»#« matches the pattern in »cy«{value}»#«
»cy«NL»gray« - »cy«{value1}»#« does not match the pattern in »cy«{value}»#«
.pg clr
Compare evaluates »cy«{value}»#« and »cy«{value1}»#« as numeric fields if
»c 132 0«BOTH»#« fields are numeric or formulae which evaluate to numeric
fields. Otherwise, the fields are evaluated as Text values.
Formula symbols and functions allowed are the same as the
»bo«/MATH»#« command.
If the comparison is »gr«TRUE»#« then execution continues at the
next line in the script. Otherwise, »%t«DO»#« branches to the
»cy«{else label}»#«. If the »cy«{else label}»#« is omitted, »ye«DO»#« branchs
to the label "»cy«:ENDIF»#«" when the comparison is »re«FALSE»#«.
Variables appearing in »cy«{value}»#« and »cy«{value1}»#« are expanded.
Both variables are converted to »c 12 0«uppercase»#« unless the "»cy«ASIS»#«"
token is included.
.pg clr
Here are some examples. First, we'll set text variable 1, zero
counter 2 and use the »bo«/MATH»#« statement to set Result variable 3
then compare them.
|/SET Name Fred
|/Math Num2 10
|/MATH Num3 10*2
.clr
Now that we have these we can use the »bo«/IF»#« command to compare
these values:
Text Variable Name »gray«= »ye«%Name»#«
Number Variable Num2 »gray«= »ye«%Num2(@@@)»#«
Number Variable Num3 »gray«= »ye«%Num3(###)»#«
.wi 1 12 79 22
|/IF %Name EQ John COMP1
:COMP1
Since »bo«FRED»#« was »re«NOT»#« »cy«EQ»#«ual to »bo«JOHN»#«, »%t«DO»#« branched to the label
»cy«COMP1»#«. Notice that "Fred" and "John" were converted to upper
before the comparison was made.
.pg clr
|/IF %Num2 NE 05 COMP2
»ye«Num = %Num2(##)»#«. Since this isn't equal to »bo«05»#«, »%t«DO»#«
continued to the next statement. »re«NOTE»gray«:»#« since both strings
are numeric, this is a »c 142 0«NUMERIC»#« comparison.
.pg clr
:COMP2
|/IF %Num3(@@@) GE 10*3
:ENDIF
Like the Counter variable comparison, this one is a NUMERIC
comparison. Since Num3 is less than 30 (10*3)
-- i.e. %Num3(@@@) -- the comparison is false and the
statement branches to the label ":ENDIF"
.pg wi 1 5 79 24 clr
The »ye«LK»#« (like) operand allows you to use "»gr«wildcard»#«" characters
to test a field. The following wildcard characters can be
used with this operator:
»wh«? »cy«= »#«Any character
»wh«# »cy«= »#«Any integer
»wh«\ »cy«= »#«next character is literal
»wh«* »cy«= »#«any string of characters
»wh«[] »cy«= »#«Groups characters inclusive
»wh«[~] »cy«= »#«Groups characters exclusive
»wh«U »cy«= »#«Any uppercase letter
»wh«L »cy«= »#«any lower case letter
»wh«@ »cy«= »#«Any alphabetic character
»wh«{|} »cy«= »#«Groups of phrases
»wh«> »cy«= »#«goto end of phrase
/BOX 4 9 42 21 14 12 " Wildcard Characters "
/PAGE 25
.wi 44 9 80 24
Here are some examples
of the use of wildcards
in »%t«/IF»#« commands. They
are similar, but more
powerful than the
wildcards which
can be used in »cy«DOS»#«
commands.
.pg clr
"»wh«ABC»+re«?»#«" will match "»cy«ABC»#«" and any
other single character.
It will match "»cy«ABCD»#«" or
"»#«ABC$»#«" but not "»re«ABC»#«" or
"»re«ABCDE»#«" because they are
too short or too long.
.pg clr
"»wh«ABC»+re«#»#«" will match "»gr«ABC»#«" and any
»ye«integer»#« (»cy«0-9»#«).
It will match "»cy«ABC1»#«" or
"»cy«ABC3»#«", but not "»cy«ABCD»#«"
or "»re«ABC12»#«".
.pg clr
"»wh«ABC»+re«*»#«" will match any string that
starts with "»cy«ABC»#«".
It will match "»cy«ABC»#«", "»cy«ABCD»#«"
or "»cy«ABC1234$@@»#«", but not
"»ye«BDF»cy«1234»#«".
.pg clr
"»+re«*»wh«XYZ»#«" Unlike »cy«DOS»#«, »%t«DO»#« can handle
the "»re«*»#«" at this start of
the phrase.
This example will match any
string ending in "»gr«XYZ»#«".
.pg clr
"»+re«*»wh«DEF»+re«*»#«" Will match a string with
"»gr«DEF»#«" anywhere in it.
.pg clr
"»wh«ABC»+re«[»wh«D»+re«-»wh«F»+re«,»wh«K»+re«]»#«"
Will match any phrase
starting with "»cy«ABC»#«" and
ending with "»gr«D»#«", "»gr«E»#«",
"»gr«F»#«" or "»gr«K»#«".
.pg clr
"»wh«ABC»+re«[~»wh«D»+re«-»wh«F»+re«,»wh«K»+re«]»#«"
Will match any phrase
starting with "»cy«ABC»#«" which
does NOT end in "»cy«D»#«", "»cy«E»#«",
"»cy«F»#«" or "»cy«K»#«".
.pg clr
"»+re«{»wh«ABC»+re«|»wh«DEF»+re«|»wh«GHI»+re«}»wh«K»#«"
Will match "»cy«ABCK»#«",
"»cy«DEFK»#«" or "»cy«GHIK»#«".
The phrases do »re«NOT»#« have
to be the same length.
.pg clr
"»wh«A»+re«>»wh«ED»#«" Will match any phrase that
starts with "»cy«A»#«" and ends in
"»cy«ED»#«".
It will match "»gr«AED»#«" or
"»gr«ABLE BODIED»#«".
.pg -24 wi 1 5 79 24 clr
The »ye«LK»#« operator can generate very complex comparisons.
The »re«NL»#« (»wh«Not Like»#«) operator is he opposite of the »ye«LK»#« operator
and is »cy«TRUE»#« when the expressions do »+re«not»#« match.
Experiment with these operators to find their true power.
:END
/ENDEXEC CLEAR